﻿using System;
using System.Collections; 
using System.Collections.Generic;
using System.IO; 
using System.Text;

namespace Parseq.Core
{
	public interface IReader 
	{
		object Peek(); 
		object Read(); 
		Location Location { get ; set ; }
	}
	
    public class CharReader : IReader , IDisposable
    {
        private BinaryReader reader;
        private Stream stream; 
        public CharReader(Stream s)
        {
            this.stream = s;
            this.reader = new BinaryReader(s);
        }

        public void Dispose()
        {
            this.stream.Dispose(); 
        }
		
		public object Peek() {
			return this.reader.PeekChar(); 
		}
		
		public object Read() {
			return this.reader.ReadChar(); 
		}

        public Location Location
        {
            get { return new Location(this.stream.Position); }
            set
            {
                this.reader.BaseStream.Position = value.Bytes; 
            }
        }
    }
}
